<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>仓库列表</title>
</head>
<body>

<!--{include file='comm/naviBanner.tpl'}-->

<div class="container">

    <!--{include file='comm/menu.tpl'}-->


        <div class="comm_crub">
            <span class="now_crub">仓库列表</span>
        </div>

        <div class="comm_content">

            <table id="flex" style="display:none"></table>

        </div>


</div>

<script type="text/javascript">
    $("#flex").flexigrid({
        url:"/invokingAjax-backend/wms/store.ajax?operFlg=1&xjx=none",
        dataType: "json",
        colModel : [
                <!--{if $EDIT_PERMISSION}-->
            {display: "操作", width : 80, align: "center"},
            {display: "是否默认", width : 80,align:"center"},
                <!--{/if}-->
            {display: "优先级", width : 80,align:"center"},
            {display: "编号", name : "storeID", width : 80, sortable : true,align:"left"},
            {display: "仓库名称", width : 140},
            {display: "仓库地址", width : 300},
            {display: "联系人", width : 80},
            {display: "联系人电话", width : 140},
            {display: "联系人手机", width : 140},
            {display: "支持地区", width : 600,align:"left"}
        ],
        <!--{if $EDIT_PERMISSION}-->
        buttons : [
            {name: "添加", bclass: "add", onpress : "store.add"},
            {separator: true},
            {name: "删除", bclass: "delete", onpress : "store.delcheck"}
        ],
        <!--{/if}-->
        sortname: "storeID",
        sortorder: "desc",
        usepager: true,
        rp: 10,
        useRp: true,
        showTableToggleBtn: true,
        onSubmit: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt});
            return true;
        }
    });

    var store = {

        delArr: new Array(),

        storeID:'',

        //删除确认
        delcheck: function(){
            //获取选中的行的行数
            var selected_count = $('.trSelected',flex).length;
            if (selected_count==0) {
                E.alert('请选择要删除的仓库');
                return;
            }else{
                var tempArr = new Array();
                for(var i=0; i<selected_count; i++){
                    var logisticsStr = $('.trSelected',flex).eq(i).attr('id');
                    var logisticsID = logisticsStr.substr(3);
                    tempArr.push(logisticsID);
                }
                this.delArr = tempArr;

                //弹出确认层
                E.confirm('是否删除这 ' + $('.trSelected',flex).length + ' 个仓库吗?', "store.del");
            }

        },

        del:function(){
            $.ajax({
                type: "POST",
                url: "/invokingAjax-backend/wms/store.ajax?operFlg=6",
                dataType: "JSON",
                data:{'delArr': store.delArr},
                success: function(result_obj){
                    if (result_obj.code == 200) {
                        E.alert(result_obj.message, 2, "store.load");
                    }
                    else {
                        E.alert(result_obj.message);
                    }
                }
            });
        },

        //搜索
        search: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt}).flexReload();
        },

        //添加
        add: function() {
            E.open("/quanliadmin/app/wms/store.pscript?operFlg=2");
        },

        //编辑
        edit: function(storeID) {
            E.open("/quanliadmin/app/wms/store.pscript?operFlg=3&storeID=" + storeID );
        },

        //区域设置
        region: function(storeID) {
            E.open("/quanliadmin/app/wms/store.pscript?operFlg=4&storeID=" + storeID, "", {height: 600,width: 980, top: 50, left: 150});
        },

        //货位列表
        shelf:function(storeID){
            E.open("/quanliadmin/app/wms/store.pscript?operFlg=5&storeID=" + storeID,'',{height : 600});
        },

        //导入货位号
        import:function(storeID){
            E.open("/quanliadmin/app/wms/store.pscript?operFlg=10&storeID=" + storeID, "", {height: 300,width: 650, top: 50, left: 300});
        },

        //货品上架
        goodsUp:function(storeID){
            E.open("/quanliadmin/app/wms/store.pscript?operFlg=12&storeID=" + storeID, "", {height: 300,width: 600, top: 50, left: 300});
        },

        //货位管理
        shelfManage:function(storeID){
            E.open("/quanliadmin/app/wms/store.pscript?operFlg=13&storeID=" + storeID, "", {height: 600,width: 800, top: 50, left: 200});
        },

        changeDefault:function(storeID,storeName){
            this.storeID = storeID;
            E.confirm('您确认将 ' + storeName + ' 设置为默认仓库吗?', "store.defaultExe");
        },

        defaultExe:function(){
            jquery_ajax(3,{storeID:this.storeID},store.callback);
        },

        //回调函数
        callback: function( obj ) {

            if( obj.code == 200 ){
                E.alert( obj.message , 2 , 'store.load');
            }else{
                E.alert(obj.message);
            }

        },

        load: function() {
            $("#flex").flexReload();
        }

    };


    function jquery_ajax(flg,data,func){
        $.ajax({
            type: "post",
            url: "/invokingAjax-backend/wms/store.ajax?operFlg="+flg,
            dataType: "json",
            data: data,
            success: function( result_obj ) {
                func(result_obj);
            },
            error : function(msg){
                alert('网络不给力，请重新尝试...');
            }
        });
    }

</script>

</body>
</html>